<template>
  <div class="cover-list">
    <div
      class="item"
      :class="numClass"
      v-for="item of listData"
      :key="item.catalogueId || item.categoryId"
      @click="toDetail(item)"
    >
      <div class="wrapper">
        <div class="cover">
          <div class="image">
            <!-- lazy -->
            <el-image
              :key="item.cover500 || item.cover200 || item.img || item.imgUrl"
              :src="item.cover500 || item.cover200 || item.img || item.imgUrl"
              fit="fill"
            >
              <div
                slot="placeholder"
                class="image-slot flex-center flex-column"
              >
                <i class="iconfont el-icon-loading"></i>
                <p>{{ $t("public.loading") }}<span class="dot">...</span></p>
              </div>
              <div slot="error" class="image-slot flex-center">
                <!-- <i class="el-icon-picture-outline"></i> -->
                <img src="@/assets/images/defaultCover.png" />
              </div>
            </el-image>
          </div>
          <!-- <div class="count">
            <i class="arrow"></i>
            <span>{{ utils.tranNumber(item.playCount, 0) }}</span>
          </div> -->
          <div class="foot ellipsis" v-if="cover == 'foot'">
            {{ $i18n.locale === "zh" ? item.cname || item.name : item.name }}
          </div>
        </div>
      </div>
      <div class="info">
        <h2
          class="name ellipsis-two"
          :class="
            toName == 'classicalSortList'
              ? 'sortInfo'
              : toName === 'jazzSortList'
              ? 'sortInfo'
              : ''
          "
          v-text="
            $i18n.locale === 'zh'
              ? item.catalogueCname ||
                item.categoryCname ||
                item.cdescription ||
                item.catalogueName ||
                item.categoryName ||
                item.description
              : item.catalogueName || item.categoryName || item.description
          "
        ></h2>
      </div>
    </div>
    <div class="item empty-box"></div>
    <div class="item empty-box"></div>
    <div class="item empty-box"></div>
    <div class="item empty-box"></div>
    <div v-if="loading" class="load-bottom">
      <nice-loading />
    </div>
  </div>
</template>

<script>
// 歌单列表组件
export default {
  data() {
    return {};
  },
  props: {
    listData: {
      type: Array,
    },
    cover: {
      type: String,
    },
    num: {
      type: Number,
      default: 5,
    },
    toName: {
      type: String,
      default: "albumDetail",
    },
    // 是否还有数据
    loadStatus: {
      type: Boolean,
    },
    // 是否显示加载更多动画
    loading: {
      type: Boolean,
    },
  },
  components: {},
  computed: {
    numClass() {
      return this.num == 2 ? "two" : "five";
    },
    isMobile() {
      return this.$store.getters.isMobile;
    },
  },
  watch: {},
  mounted() {},
  methods: {
    toDetail(item) {
      if (this.$route.name == "classicalResource") {
        // window.location.href = item.jumpUrl;
        window.open(item.jumpUrl, "_blank");
        return;
      }
      let params = {
        sort:
          item.moduleId == 516
            ? "classical"
            : item.moduleId == 518
            ? "national"
            : "jazz",
        id: item.catalogueId || item.categoryId || item.resourceId,
      };
      // console.log(params)
      this.$router.push({
        name: this.toName,
        params,
      });
    },
  },
  created() {},
};
</script>
<style lang="scss" scoped>
.cover-list {
  overflow: auto;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  // margin: 0 -15px 20px -15px;
  .item {
    flex: 0 0 19%;
    max-width: 20%;
    margin-top: 20px;
    // padding: 0 10px 30px;
    cursor: pointer;
    &.two {
      flex: 0 0 50%;
      max-width: 50%;
    }
    .wrapper {
      position: relative;
      // &:before,
      // &:after {
      //   content: "";
      //   width: 100%;
      //   height: 100%;
      //   background-color: #d9d9d9;
      //   position: absolute;
      //   top: 0;
      //   transition: all 0.4s;
      // }
      // &:before {
      //   right: 6px;
      //   transform: scale(0.85);
      //   transform-origin: 100% 50%;
      //   z-index: 2;
      //   border-radius: 2px;
      // }
      // &:after {
      //   right: 4px;
      //   transform: scale(0.73);
      //   transform-origin: 100% 50%;
      //   z-index: 1;
      //   border-radius: 2px;
      //   opacity: 0.5;
      // }
      .cover {
        position: relative;
        z-index: 2;
        padding-top: 100%;
        border-radius: 2px;
        background-color: #d9d9d9;
        .el-image {
          position: absolute;
          top: 0;
          left: 0;
          overflow: hidden;
          height: 100%;
          width: 100%;
          text-align: center;
          &:after {
            content: "";
            position: absolute;
            top: 0;
            left: 0;
            // width: 100%;
            // height: 100%;
            border-radius: 2px;
            -webkit-box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.05) inset,
              -1px -1px 0 rgba(0, 0, 0, 0.05) inset;
            box-shadow: inset 1px 1px 0 rgba(0, 0, 0, 0.05),
              inset -1px -1px 0 rgba(0, 0, 0, 0.05);
          }
          img {
            width: 100%;
            height: auto;
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
          }
        }
        .count {
          position: absolute;
          right: 16px;
          top: 1px;
          height: 24px;
          padding-left: 9px;
          background: url(https://img.alicdn.com/tfs/TB1xEGRub9YBuNjy0FgXXcxcXXa-268-48.png)
            no-repeat 0;
          background-size: cover;
          color: #fff;
          font-size: 12px;
          font-weight: 700;
          line-height: 24px;
          display: flex;
          align-items: center;
          justify-content: center;
          .arrow {
            display: block;
            width: 0;
            height: 0;
            border-style: solid;
            border-width: 4px 0 4px 6px;
            border-color: transparent transparent transparent #ffffff;
            margin-right: 5px;
          }
          &:after {
            content: "";
            position: absolute;
            right: -14px;
            top: 0;
            width: 14px;
            height: 24px;
            background: url(https://img.alicdn.com/tfs/TB1xEGRub9YBuNjy0FgXXcxcXXa-268-48.png)
              no-repeat 100%;
            background-size: cover;
          }
        }
        .foot {
          width: 100%;
          height: 40px;
          text-align: center;
          line-height: 40px;
          background: rgba(255, 255, 255, 0.7);
          color: #000;
          position: absolute;
          left: 0;
          bottom: 0;
          font-size: 20px;
        }
      }
    }
    .info {
      margin-top: 10px;
      .name {
        font-size: 16px;
      }
      .sortInfo {
        font-size: 20px;
        color: #000000;
        font-weight: 600;
      }
    }
    &:hover {
      .wrapper {
        &:before,
        &:after {
          background: rgba(250, 40, 0, 0.1);
        }
        &:before {
          right: 4px;
        }
        &:after {
          right: 0px;
        }
      }
    }
  }
  .load-bottom {
    width: 100%;
    margin: auto;
  }
}
</style>
